package com.situ.b2c.catalog.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;

import com.situ.b2c.catalog.service.CatalogService;
import com.situ.b2c.pojo.Catalog;


@WebServlet("/CatalogGoUpdateServlet")
public class CatalogGoUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
   private CatalogService catalogService;
	
    public CatalogGoUpdateServlet() {
       ApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
       catalogService = context.getBean(CatalogService.class);
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Long rowId= Long.parseLong(request.getParameter("rowId"));
		
		Catalog catalog = catalogService.selectOneById(rowId);
		request.setAttribute("catalog", catalog);
		
		request.getRequestDispatcher("B2Choutai/catalog_update.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
